package com.hdax.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hdax.entity.Car;
import com.hdax.dao.CarMapper;
import com.hdax.service.CarService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ${author}
 * @since 2021-03-22
 */
@Service
public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements CarService {
    @Override
    public Map<String, Object> listByPage(int page, int pageSize, Car series) {
        Page<Car> car=new Page<Car>(page,pageSize);
        QueryWrapper queryWrapper=new QueryWrapper();
        if(series!=null){
            if(series.getSeries()!=null&& !series.getSeries().trim().equals("")){
                queryWrapper.like("series",series.getSeries());
            }
        }
        IPage iPage=page(car,queryWrapper);
        Map<String,Object>map=new HashMap<String, Object>();
        map.put("data",iPage.getRecords());
        map.put("count",iPage.getTotal());
        return map;
    }

    @Override
    public int btnDel(List<Integer> ids) {
        return baseMapper.btnDel(ids);
    }
}
